package fr.snac.bm;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import fr.snac.utils.Constants;

@SuppressLint("NewApi")
public class PreferencesActivity extends Activity {


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.pref_layout);

		FragmentManager manager = getFragmentManager();
		FragmentTransaction transaction = manager.beginTransaction();
		PreferencesFragment fragment = new PreferencesFragment();

		transaction.replace(android.R.id.content, fragment);
		transaction.commit();


		SharedPreferences settings = getSharedPreferences(Constants.SETTINGS_PREFERENCES, 0);
		Log.d("BONJOURACTIVITY", "PREF lecture : " + settings.getString(Constants.SETTINGS_CURRENT_DATE, Constants.SETTINGS_NULL));

	}

	@SuppressLint("InlinedApi")
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.bonjour, menu);

		if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= 14){
			MenuItem home = menu.findItem(android.R.id.home);
			home.setVisible(false);
		}

		menu.findItem(R.id.menuDefineFavourite).setVisible(false);
		menu.findItem(R.id.menuSearch).setVisible(false);
		menu.findItem(R.id.menuSettings).setVisible(false);
		menu.findItem(R.id.menuShare).setVisible(false);
		menu.findItem(R.id.menuShowFavourite).setVisible(false);
		menu.findItem(R.id.menuWallpaper).setVisible(false);

		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		return super.onOptionsItemSelected(item);
	}
}
